package cn.winwintech.Incense.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.base.webapp.model.BaseModel;

@Entity
@Table(name = "tree")
public class Tree extends BaseModel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6017463313126693741L;
	private String treeId; // 树苗ID
	private String traCodeId;// 钉子ID
	private String name;
	private TreeType type;
	private Double latitude;
	private Double longitude;

	public String getName() {
		return name;
	}

	@Id
	@Column(length = 20)
	public String getTreeId() {
		return treeId;
	}

	public void setTreeId(String treeId) {
		this.treeId = treeId;
	}

	public String getTraCodeId() {
		return traCodeId;
	}

	public void setTraCodeId(String traCodeId) {
		this.traCodeId = traCodeId;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne(targetEntity = TreeType.class)
	public TreeType getType() {
		return type;
	}

	public void setType(TreeType type) {
		this.type = type;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
		result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((traCodeId == null) ? 0 : traCodeId.hashCode());
		result = prime * result + ((treeId == null) ? 0 : treeId.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Tree other = (Tree) obj;
		if (latitude == null) {
			if (other.latitude != null)
				return false;
		} else if (!latitude.equals(other.latitude))
			return false;
		if (longitude == null) {
			if (other.longitude != null)
				return false;
		} else if (!longitude.equals(other.longitude))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (traCodeId == null) {
			if (other.traCodeId != null)
				return false;
		} else if (!traCodeId.equals(other.traCodeId))
			return false;
		if (treeId == null) {
			if (other.treeId != null)
				return false;
		} else if (!treeId.equals(other.treeId))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Tree [treeId=" + treeId + ", traCodeId=" + traCodeId + ", name=" + name + ", type=" + type
				+ ", latitude=" + latitude + ", longitude=" + longitude + "]";
	}

}
